package UnitTest.DataStructureTest.stackHeapQueueTest.heapTest;

import DataStructure.heapStackQueue.heap.WordFrequency;
import Logic.utils.ArrayUtilsImpl;
import Logic.dbUtils.DBTools;
import Logic.dbUtils.SQLTestDataEntity;
import Logic.utils.UTFactory;
import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.sql.SQLException;

/**
 * @author liujun
 * @version V1.0
 * @date 2022/3/12 11:03 PM
 * @author-Email ljfirst@mail.ustc.edu.cn
 * @description 词频统计 测试案例
 */
public class WordFrequencyTest {

    @Test
    public void test() throws SQLException {

        WordFrequency instance = new WordFrequency();
        List<SQLTestDataEntity> list = DBTools.getSqlResult("WordFrequency");

        for (SQLTestDataEntity entity : list) {
            String[] answer = instance.Solution(entity.getStringArrayInput());
            if (!ArrayUtilsImpl.StringArrayEquals(answer, entity.getStringArrayOutput())) {
                System.out.println("answer: " + Arrays.deepToString(answer));
                entity.print();
            }
        }
    }

    // 每个String出现至少3次，期望输出："a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1",
    String[] demo01 = {
            "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1",
            "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1",
            "a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1",
            "a3", "b1", "c3", "d1", "e3", "f3", "g1", "h3", "i1", "j1",
            "a2", "b2", "c2", "d2", "e2", "f2", "g2", "h2", "i2", "j2",
    };
    String[] target01 = {"a1", "b1", "c1", "d1", "e1", "f1", "g1", "h1", "i1", "j1"};
}
